﻿using NetCore8Demo.Models.PLC;
using NetCore8Demo.Tool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetCore8Demo.Models.Axis
{
    public class AxisInfo
    {
        public Guid Id;
        public short AxisId ;
        public string Name="";
        //排序号
        public int Index ;

       

        //Jog运动参数
        public double JogVel ;
        public double JogAcc ;
        public double JogDec ;
        public double JogSmoothTime ;

        //Trap运动参数
        public double TrapVel ;
        public double TrapAcc ;
        public double TrapDec ;
        public short TrapSmoothTime ;

        //回零运动参数
        public HomeModeType HomeModeMode ;
        public HomeDirectionType HomeDirection;
        public short HomeHighVel ;
        public short HomeLowVel ;
        public double HomeAcc ;
        public double HomeDec ;
        public short IndexDirection ;


        //实际距离需要多少脉冲
        public double DistanceToPulse;
        public int Band;// 误差带大小。单位：脉冲。
        public int BandTime;//误差带保持时间。单位：250 微秒。 1毫秒等于1000微秒

    }

    //回零方式
    public enum HomeModeType
    {
        限位加原点回零,
        原点回零,
        限位回零,
    }

    //回零方向
    public enum HomeDirectionType
    {
        正方向回零,
        负方向回零,
    }

    public class StaticAxis
    {
        public static bool InitAxisFlag;

        public static string SavePath = "Axis";
        public static string SaveName = "AxisInfoList";

        public static List<AxisInfo> AxisInfoList = new();

        public static void InitStaticAxisInfoList()
        {
            AxisInfoList = JsonParam.LoadParamPath<List<AxisInfo>>(SavePath, SaveName) ??
                           new List<AxisInfo>();
        }

        public static List<AxisInfo> LoadAxisInfoList()
        {
            List<AxisInfo> axisInfoList = new();

            axisInfoList = JsonParam.LoadParamPath<List<AxisInfo>>(SavePath, SaveName) ??
                           new List<AxisInfo>();
            return axisInfoList;

        }

        public static bool SavaAxisInfoList(List<AxisInfo> axisInfoList)
        {
            return JsonParam.SaveParamPath(SavePath, SaveName, axisInfoList);
        }


    }
}
